#include <iostream>
#include <string>

// 定义一个简单的类
class Person {
public:
    Person(const std::string &name, int age) : name(name), age(age) {
    }

    ~Person() {
    }

    std::string public_name;

    void introduce() const {
        std::cout << "My name is " << name << " and I'm " << age << " years old." << std::endl;
    }

private:
    std::string name;
    int age;
};


int main() {
    // 创建普通对象
    Person person1("Alice", 25);
    std::cout << "Using ordinary object:" << std::endl;
    person1.introduce();

    // 创建指针对象
    Person *personPtr = new Person("Bob", 30);
    std::cout << "\nUsing pointer object:" << std::endl;
    // 使用 -> 操作符访问成员函数
    personPtr->introduce();

    // 释放指针对象占用的内存
    delete personPtr;

    return 0;
}
